<include file="public@header"/>
<style>
	/*table{ border:1px solid #000; width:80%; font-size:1rem; margin-bottom:20px}
	td{border:1px solid #000; padding:0 5px; height:2rem; text-align:center}*/
	/*tr td input,tr td  { width:90px;}*/
	.content_nav    .check_info{flex:1; display:flex;flex-direction: column;align-items: center;justify-content: center;}
	.form-horizontal .control-group1 {
		float: left;
		width: 15%;
		margin-bottom: 20px;
	}
	.form-horizontal .control-label {width:80px;}
	.form-horizontal .controls {margin-left:90px;}
	input,select, textarea, .uneditable-input {
		max-width: 580px;
		width:100px;
		min-width:auto;
	}
</style>
</head>
<body>
	<div class="wrap js-check-wrap">
		<ul class="nav nav-tabs">
			<li class="active"><a href="{:url('Aftersale/back')}">申请退墓</a></li>
		</ul>
        <form class="form-horizontal js-ajax-form" action="{:url('')}" method="post" enctype="multipart/form-data">
        <fieldset>
        <!--改版画面-->
        <div class="div_title"><span>客户概览</span></div>
        <div class="control-group1-p div_content">
        	<div class="control-group1">
                <label class="control-label">客户姓名</label>
                <div class="controls">
                    <input type="text" class="form-control" value="{$result.buyer_name}" disabled>
                </div>
            </div>
            <div class="control-group1">
                <label class="control-label">持证类型</label>
                <div class="controls">
                    <input type="text" class="form-control" value="{:cart_type('cart',$result.cart_type)}" disabled>
                </div>
            </div>
            <div class="control-group1">
                <label class="control-label">证件号码</label>
                <div class="controls">
                    <input type="text" class="form-control" style="width:150px;" value="{$result.customer_account}" disabled>
                </div>
            </div>
            <div class="control-group1">
                <label class="control-label">联系电话</label>
                <div class="controls">
                    <input type="text" class="form-control" value="{$result.buyer_phone}" disabled>
                </div>
            </div>
            <div class="control-group1" style="width:40%;">
                <label class="control-label">联系地址</label>
                <div class="controls">
                    <input type="text" class="form-control" value="{$result.customer_address}" style="width:80%;" disabled>
                </div>
            </div>
            <div class="control-group1">
                <label class="control-label">合同编号</label>
                <div class="controls">
                    <input type="text" class="form-control" value="{$result.contract_sn}" disabled>
                </div>
            </div>
            <div class="control-group1">
                <label class="control-label">购买日期</label>
                <div class="controls">
                    <input type="text" class="form-control" value="{$result.gm_start_time}" disabled>
                </div>
            </div>
            <div class="control-group1">
                <label class="control-label">打证日期</label>
                <div class="controls">
                    <input type="text" class="form-control" value="{$result.dz_start_time}" disabled>
                </div>
            </div>
            <div class="control-group1">
                <label class="control-label">保修状态</label>
                <div class="controls">
                    <input type="text" class="form-control" value="{$result.bxq_status}" disabled>
                </div>
            </div>
            <div class="control-group1">
                <label class="control-label">当前状态</label>
                <div class="controls">
                    <input type="text" class="form-control" value="{$result.col_status_name}" disabled>
                </div>
            </div>
            <div class="control-group1">
                <label class="control-label">维护期</label>
                <div class="controls">
                    <input type="text" class="form-control" value="{$result.whq_status}" disabled>
                </div>
            </div>
            <div class="control-group1">
                <label class="control-label">墓位编号</label>
                <div class="controls">
                    <input type="text" class="form-control" value="{$result.tomb_num}" disabled>
                </div>
            </div>
            <div class="control-group1">
                <label class="control-label">具体位置</label>
                <div class="controls">
                    <input type="text" class="form-control" style="width:150px;" value="{$result.tomb_region}{$result.tomb_address}" disabled>
                </div>
            </div>
            <div class="control-group1">
                <label class="control-label">墓穴规制</label>
                <div class="controls">
                    <input type="text" class="form-control" value="{$result.tomb_regulation_name}" disabled>
                </div>
            </div>
            <div class="control-group1">
                <label class="control-label">零售价格</label>
                <div class="controls">
                    <input type="text" class="form-control" value="{$result.selling_price}" disabled>
                </div>
            </div>
            <div class="control-group1">
                <label class="control-label">优惠比例</label>
                <div class="controls">
                    <input type="text" class="form-control" value="{$result.discount_ratio}" disabled>
                </div>
            </div>
            <div class="control-group1">
                <label class="control-label">免零金额</label>
                <div class="controls">
                    <input type="text" class="form-control" value="{$result.free_price}" disabled>
                </div>
            </div>
            <div class="control-group1">
                <label class="control-label"><font color="red">成交价格</font></label>
                <div class="controls">
                    <input type="text" class="form-control" value="{$result.closing_price}" disabled>
                </div>
            </div>
             <div class="control-group1">
                <label class="control-label">收款人</label>
                <div class="controls">
                    <input type="text" class="form-control" value="{$pay_real_name|default=''}" disabled>
                </div>
            </div>
             <div class="control-group1">
                <label class="control-label">导购员</label>
                <div class="controls">
                    <input type="text" class="form-control" value="{$result.shoppingguide}" disabled>
                </div>
            </div>
             <div class="control-group1">
                <label class="control-label" >代理商</label>
                <div class="controls" >
                    <input type="text" class="form-control" value="{$result.agent_user}" disabled>
                </div>
            </div>
             <div class="control-group1">
                <label class="control-label">抵顶人</label>
                <div class="controls">
                    <input type="text" class="form-control" value="{$result.reacher}" disabled>
                </div>
            </div>
            <!---tab页-->
            <ul class="nav_tabs">
                <if condition=" $approval_id neq '' ">
                <li class="active_1"><a href="javascript:">办理退墓</a></li>
                <li class="active_2 active"><a href="javascript:">审核意见</a></li>
                    <else />
                    <li class="active"><a href="javascript:">办理退墓</a></li>
                    <li><a href="javascript:">审核意见</a></li>
                </if>
            </ul>
            <div class="control-group1-p nav_content">
            	<div class="content_nav feature_1 {$feature_x} " >
                	<div class="p_title">
                        <span class="span_title">手续回收</span>
                    </div>
                    <div class="control-group1-p" style="border:1px solid #e2e2e2; padding-top:20px;margin:0 20px;overflow:hidden; overflow-x:auto;">
                        <table class="table table-hover table-bordered">
                            <thead>
                                <tr>
                                    <th>持证人</th>
                                    <th>性别</th>
                                    <th>手机号码</th>
                                    <th></th>
                                    <th>联系地址</th>
                                    <th>身份证</th>
                                    <th >付款凭证</th>
                                    <th>墓穴使用合同</th>
                                    <th>墓穴安葬证</th>
                                </tr>
                            </thead>
                            <tbody>
                                <tr>
                                    <td><input type="text" class="form-control" name="deceased[certificate_name]" value="{$result.buyer_name|default=''}"></td>
                                    <td><select name="deceased[certificate_sex]" class="form-control">
                                        <if condition="isset($result['certificate_sex']) ">
                                            <option value='1'<if condition="'1' eq $result['certificate_sex']">selected</if>>男</option>
                                            <option value="2" <if condition="'2' eq $result['certificate_sex']">selected</if>>女</option>
                                            <else>
                                                <option value='1'>男</option>
                                                <option value="2">女</option>
                                            </else>
                                        </if>

                                    </select>
                                    </td>
                                    <td><input type="text" class="form-control" name="deceased[certificate_phone]" value="{$result.buyer_phone|default=''}"></td>
                                    <td><input type="checkbox" name="deceased[is_sms]"  checked  value="1" style="width: 20px;">短信通知</td>
                                    <td><input type="text" class="form-control" name="deceased[certificate_address]" value="{$result.buyer_address|default=''}"></td>
                                    <td>
                                        <php>$img_urls=cmf_get_image_preview_url(isset($retreat['cart_file'])?$retreat['cart_file']:'');</php>
                                        <input type="hidden" name="deceased[cart_file]" id="cart_file" value="{$retreat.cart_file|default=''}">
                                        <a href="javascript:gpyUploadOneImage('上传证件', '#cart_file','{$result.tomb_num}');">
                                            <h5 class="btn btn-primary">拍照上传</h5>
                                        </a>
                                        <img height="50" src="{$img_urls}" onclick="parent.imagePreviewDialog(this.src);"  id="cart_file-preview" style="cursor: hand"/>
                                    </td>
                                    <td>
                                        <php>$img_p=cmf_get_image_preview_url(isset($retreat['pay_file'])?$retreat['pay_file']:'');</php>
                                        <input type="hidden" name="deceased[pay_file]" id="pay_file" value="{$retreat.pay_file|default=''}">
                                        <a href="javascript:gpyUploadOneImage('上传证件', '#pay_file','{$result.tomb_num}');">
                                            <h5 class="btn btn-primary">拍照上传</h5>
                                        </a>
                                        <img height="50" src="{$img_p}"onclick="parent.imagePreviewDialog(this.src);"  id="pay_file-preview" style="cursor: hand"/>
                                    </td>
                                    <td>
                                        <php>$img_ht=cmf_get_image_preview_url(isset($retreat['ht_file'])?$retreat['ht_file']:'');</php>
                                        <input type="hidden" name="deceased[ht_file]" id="ht_file" value="{$retreat.ht_file|default=''}">
                                        <a href="javascript:gpyUploadOneImage('上传证件', '#ht_file','{$result.tomb_num}');">
                                            <h5 class="btn btn-primary">拍照上传</h5>
                                        </a>
                                        <img src="{$img_ht}" id="ht_file-preview" onclick="parent.imagePreviewDialog(this.src);"  width="50" style="cursor: hand"/>
                                    </td>
                                    <td>
                                        <php>$img_az=cmf_get_image_preview_url(isset($retreat['az_file'])?$retreat['az_file']:'');</php>
                                        <input type="hidden" name="deceased[az_file]" id="az_file" value="{$retreat.az_file|default=''}">
                                        <a href="javascript:gpyUploadOneImage('图片上传','#az_file','{$result.tomb_num}');">
                                            <h5 class="btn btn-primary">拍照上传</h5>
                                        </a>
                                        <img src="{$img_az}" id="az_file-preview" onclick="parent.imagePreviewDialog(this.src);"  width="50" style="cursor: hand"/>
                                    </td>
                                </tr>
                            </tbody>
                        </table>

                    </div>
                    <div class="p_title">
                        <span class="span_title">退墓详情</span>
                    </div>
                    <div class="control-group1-p" style="border:1px solid #e2e2e2; padding-top:20px;margin:0 20px;overflow:hidden; overflow-x:auto;">
                    <table class="table table-hover table-bordered">
                        <thead>
                            <tr>
                                <th style="width:25%;">退墓原因</th>
                                <th>成交价格</th>    
                                <th>折损比例</th>                                                                    
                                <th>实退金额</th>
                                <th>退款方式</th>  
                                <th >原件回收</th>                      
                                <th >经办人</th>                                
                                <th>办理时间</th>
                            </tr>
                        </thead>
                        <tbody>
                            <tr>
                            	<td><select name="tmxq[reason_info]" style="width:250px;" class="form-control">
                                        <option value="">选择退墓原因</option>
                                        <foreach name="refund_reason" item="vo">
                                            <if condition="isset($retreat['reason_info'])">
                                                <option value="{$vo}" <if condition="$vo eq  $retreat['reason_info'] ">selected </if>>{$vo}</option>
                                                <else/>
                                                <option value="{$vo}"  >{$vo}</option>
                                            </if>
                                        </foreach>
                                    </select>
                                </td>
                                <td><input type="text" class="form-control closing_price" name="tmxq[closing_price]" value="{$result.closing_price}"></td>
                                <td><select name="tmxq[loss_ratio]" class="form-control loss_ratio">
                                    <option value="0">0%</option>
                                    <option value="0.3">30%</option>
                                    <option value="0.7">70%</option>

                                    </select>
                                </td>
                                <td><input type="text" class="form-control refund_amount" name="tmxq[refund_amount]" value="{$retreat.refund_amount|default=''}"></td>
                                <td>
                                    <select name="tmxq[refund_type]"   class="form-control">
                                        <foreach name="pay_type" item="vo">
                                            <if condition="isset($retreat['refund_type'])">
                                                <option value="{$key}" <if condition="$key eq  $retreat['refund_type'] ">selected </if>>{$vo}</option>
                                                <else/>
                                                <option value="{$key}"  >{$vo}</option>
                                            </if>
                                        </foreach>
                                    </select>
                                </td>
                                <td>
                                    <input type="hidden" name="tmxq[is_recycle]" id="is_recycle" value="0">
                                    <div class="btn btn-primary" id="check-is_recycle">确认回收</div>
                                </td>
                                <td><input type="text" class="form-control" name="handle_user" value="{:cmf_get_admin_name()}" disabled></td>
                                <td><input type="text" class="form-control js-date" name="tmxq[add_time]" value="{$add_time}" autocomplete="off"></td>
                            </tr>
                        </tbody>
                    </table>

                  </div>                  
                  <div class="form-actions">
                      <input type="hidden" name="payid"  value="{$pay_info.id}">
                      <input type="hidden" name="id"  value="{$retreat.id|default=''}">
                      <input type="hidden" name="approval_id"  value="{$retreat.approval_id|default=''}">
                      <input type="hidden" name="otype" id="otype" value="0">
                      <input type="hidden" name="order_id" value="{$result.order_id|default=''}">
                      <input type="hidden" name="mw_id" value="{$result.tomb_id|default=''}">
                      <input type="hidden" name="mw_num" value="{$result.tomb_num|default=''}">
<!--                        <div class="btn btn-primary" id="tjbtn">保存</div>-->
                        <div class="btn btn-primary" id="tjshbtn">提交审核</div>
                  </div>
                </div >
                <div class="content_nav check_nav feature_2  {$feature_xq}"  >
                    <!--<if condition="isset($retreat['approval_status'])">-->
                       <!--<if condition="$retreat['approval_status'] eq 1 ">-->
                        <div class="check_info">
                            <P style="color:#0b7ebf">您的退墓申请已于{$apply_time}成功提交</P>
                            <P>申请处理中，请耐心等待！</P>
                            <div class="btn btn-primary" id="check-cktj">查看提交内容</div>
                        </div>
                           <!--<elseif condition="$retreat.approval_status eq 2" /> -->
                    <div class="check_info">
                            <img src="__TMPL__/Public/assets/images/agree.jpg" />
                            <P style="color:#4ABD41;font-size:20px;">您的退墓申请已申请通过</P>
                            <P style="color:#999999;">{$retreat.approval_time|date='Y-m-d H;i:s'}</P>
                            <div>您的退墓费将于30个工作日到账，退款后工作人员会与您及时联系</div>
                            <div class="btn btn-primary check-btn_print" style="margin-top:10px;" data-id="{$retreat.id|default=''}" data-url="{:url('Print/print_cert')}mark=3&type=1&refund_id={$retreat.id|default=''}">打印《退墓通知单》</div>
                    </div>
                           <!--<elseif condition="$retreat.approval_status eq 3" /> -->
                    <div class="check_info">
                        <img src="__TMPL__/Public/assets/images/warn.jpg" />
                        <P style="color:#EE860A;font-size:20px;">您的退墓申请已未申请通过</P>
                        <P style="color:#999999;">{$retreat.approval_time|date='Y-m-d H;i:s'}</P>
                        <div style="padding:5px;max-width:200px;border:1px solid #f2f2f2;">未通过原因：{$retreat.approval_desc}</div>
                        <div class="btn btn-primary" id="check-fh" style="margin-top:10px;">返回修改</div>
                    </div>

                        <!-- <else />-->

                         <!--</if>-->

                         <!--<else />-->
                    <!-- </if>-->

                </div>
                <div class="content_nav feature"></div>
            </div>
        </div>
        </fieldset>
        </form>
    </div>
    <div id="print_html" style="display: none"></div>
	<script type="text/javascript" src="__STATIC__/js/admin.js?v={:time()}"></script>

    <script type="text/javascript" src="__STATIC__/js/lodop/LodopFuncs.js?v={:time()}"></script>
    <script type="text/javascript" src="__STATIC__/js/print.js?1"></script>
	<script type="text/javascript">
        $('#check-is_recycle').click(function () {
             $(this).text('已回收');
             $(this).attr('disabled',true);
             $('#is_recycle').val(1);
        })
        $('.loss_ratio').change(function () {
            var loss_ratio = 1-($(this).val());
            var closing_price = $('.closing_price').val();
            var refund_amount = closing_price*loss_ratio;
            $('.refund_amount').val(refund_amount.toFixed(2))

        })
	//切换显示
	$(document).on('click','.nav_tabs li',function(){
		$(this).addClass('active').siblings().removeClass('active');
		var index = $(".nav_tabs li").index(this);
		billtype = index;
		console.log(index);		
		$('.content_nav').eq(index).removeClass("feature").siblings().addClass("feature");
    });
    // 保存
    $("#tjbtn").click(function(){
        $("#otype").val(0);
        $.post($(".form-horizontal").attr('action'), $(".form-horizontal").serialize(), function(result){
            if(result.state == 'success'){
                layer.msg(result.msg);
            } else {
                layer.msg(result.msg);
            }
        }, 'json');
    });
    //提交审核
    $("#tjshbtn").click(function(){
        $("#otype").val(1);
        $.post($(".form-horizontal").attr('.form-horizontal'), $("form").serialize(), function(result){
            if(result.code == 1){
                layer.msg(result.msg);
                window.location.href = result.url;
            } else {
                layer.msg(result.msg);
            }
        }, 'json');
    });
    $('.check-btn_print').click(function () {
        var url = $(this).attr('data-url');
        var id = $(this).attr('data-id');
        $.ajax({
            type: "get", url:"{:url('Print/print_cert')}?mark=3&type=1&refund_id="+id,
            success: function (strHtml) {
                console.log('打印')
                var data = strHtml.data;
                $('#print_html').html(data.html)
                preViewPrint('服务结算单',3,7)
            }
        })
    })
    $('#check-cktj').click(function () {
        console.log(123)
        $('.active_1').addClass('active');
        $('.active_2').removeClass('active');
        $('.feature_1').removeClass("feature");
        $('.feature_2').addClass("feature");
        $('#tjbtn').attr('disabled','disabled');
        $('#tjshbtn').attr('disabled','disabled');
    })
    $('#check-fh').click(function () {
        console.log(123)
        $('.active_1').addClass('active');
        $('.active_2').removeClass('active');
        $('.feature_1').removeClass("feature");
        $('.feature_2').addClass("feature");
        $('#tjbtn').attr('disabled','');
        $('#tjshbtn').attr('disabled','');
    })
    </script>

</body>
</html>